﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WastedMechanics
{
    public class Equipment
    {
        public List<Item> Items;        
        public float Capacity;
        float _weight;

        public Equipment()
        {
            Items = new List<Item>();
        }

        public float Weight
        {
            get
            {
                return _weight;
            }
        }

        public bool AddItem(Item item)
        {
            Console.WriteLine(item.Name);
            if (_weight + item.Weight <= Capacity)
            {
                Items.Add(item);
                _weight += item.Weight;                
                return true;
            }
            return false;
        }

        public bool CanReceive(Item item)
        {
            return _weight + item.Weight <= Capacity;
        }

        public bool RemoveItem(Item item)
        {
            if (Items.Contains(item))
            {
                Items.Remove(item);
                _weight -= item.Weight;
                return true;
            }
            return false;
        }        

        public Item Get(string name)
        {            
            return Items.Find(item => item.Name == name);
        }
    }
}
